package com.example.blog1.mapper;

import com.example.blog1.model.BlogInfo;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface BlogInfoMapper {
    @Select("select * from blog where delete_flag=0")
    List<BlogInfo> getBlogList();

    @Select("select user_id from blog where id=#{id}")
    Integer queryUserIdByBlogId(Integer id);

    @Select("select * from blog where id=#{id}")
    BlogInfo queryBlogByBlogId(Integer id);

    Integer update(@Param("title") String title, @Param("content") String content, @Param("id") Integer id);

    @Insert("insert into blog(title,content,user_id) values(#{title},#{content},#{userId})")
    Integer add(BlogInfo blogInfo);

    @Update("update blog set delete_flag=1 where id=#{id}")
    Integer delete(@Param("id") Integer id);
}
